package pi

func calculatePi(num float64) float64 {
	return 4.0 / (1.0 + num*num)
}

func Calculate(n int64, start, end int64, c chan float64) {
	var sum float64 = 0.0
	var h float64 = 1.0 / float64(n)
	for i := start; i < end; i++ {
		x := h * (float64(i) + 0.5)
		sum += calculatePi(x)
	}
	c <- sum * h
}
